package com.leyou.item.api;

import com.leyou.item.bo.SpuBo;
import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.SpuDetail;
import com.leyou.common.pojo.PageResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * Feature:商品服务接口
 */
@RequestMapping("goods")
public interface GoodsApi {
    /**
     * 分页查询商品
     * @param page
     * @param rows
     * @param sortBy
     * @param desc
     * @param key
     * @param saleable
     * @return
     */
    @GetMapping("spu/page")
    public PageResult<SpuBo> querySpuByPageAndSort(@RequestParam(name = "page", defaultValue = "1") Integer page,
                                                   @RequestParam(name = "rows", defaultValue = "5") Integer rows,
                                                   @RequestParam(name = "sortBy", required = false) String sortBy,
                                                   @RequestParam(name = "desc", defaultValue = "false") Boolean desc,
                                                   @RequestParam(name = "key", required = false) String key,
                                                   @RequestParam(name = "saleable", defaultValue = "true") Boolean saleable);

    /**
     * 新增商品
     * @param spu
     * @return
     */
    @PostMapping
    public ResponseEntity<Void> saveGoods(@RequestBody SpuBo spu);

    /**
     * 商品上下架(单个、批量)
     * @param ids
     * @return
     */
    @PutMapping("spu/out/{id}")
    public ResponseEntity<Void> goodsSoldOutPut(@PathVariable("id") String ids);

    /**
     * 商品删除(单个、批量)
     * @param ids
     * @return
     */
    @DeleteMapping("spu/{id}")
    public ResponseEntity<Void> deleteGoods(@PathVariable("id") String ids);

    /**
     * 商品修改
     * @param spuBo
     * @return
     */
    @PutMapping
    public ResponseEntity<Void> updateGoods(@RequestBody SpuBo spuBo);

    /**
     * 商品回显:根据id查询商品信息
     * @param id
     * @return
     */
    @GetMapping("spu/{id}")
    public SpuBo queryGoodsBySpuId(@PathVariable("id") Long id);

    /**
     * 根据spuId查询所有的List<Sku>
     * @param id
     * @return
     */
    @GetMapping("sku/list/{id}")
    public List<Sku> querySkuBySpuId(@PathVariable("id") Long id);

    /**
     * 根据spuId查询SpuDetail
     * @param id
     * @return
     */
    @GetMapping("spu/detail/{id}")
    public SpuDetail querySpuDetailBySpuId(@PathVariable("id") Long id);

    /**
     * 根据skuId来查询sku对象
     * @param id
     * @return
     */
    @GetMapping("sku/{id}")
    public Sku querySkuById(@PathVariable("id") Long id);

}
